package com.testfileupload.uploadimg.design.proxy.dynamic.dc2;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

import static com.testfileupload.uploadimg.design.proxy.dynamic.dc2.DynamicProxy.newProxyInstence;

public class DynamicProxy2<T> {
    private static boolean flag = true;

    public static <T> T newProxyInstence2(Subject subject) {
        //寻找切点joinpoint
        new BeforeAdvice().exec();
        ClassLoader classLoader = subject.getClass().getClassLoader();
        Class<?>[] interfaces = subject.getClass().getInterfaces();
        InvocationHandler invocationHandler = new MyInvocationHandler(subject);
        return (T) Proxy.newProxyInstance(classLoader, interfaces, invocationHandler);
    }
}
